jQuery(document).ready(function() {

    // Override default error message
    jQuery.validator.messages.required = "";

    // Override generation of error label
    $("#post").validate({
        submitHandler: function(form) {

            $('input[type=submit]', '#post').attr('disabled', 'disabled');
            $('#ajax-loading').css('visibility', 'visible');

            var form = $("#post");
            var form_data = form.serialize();

            $.ajax({
                url: base_url + 'seo/submit',
                dataType: 'json',
                type: "POST",
                data: form_data,
                success: function(data, textStatus, xhr) {
                    jQuery('#ajax-loading').css('visibility', 'hidden');

                    if (data.action == true) {

                        jQuery('.loader').html(data.msg);

                        // REDIRECT
                        function promo_show() {
                            window.location.href = base_url + 'seo/view_all?post_type='+post_type;
                        }
                        window.setTimeout(function() {
                            promo_show();
                        }, 1001);

                    } else {

                        $('#post').removeAttr('disabled');
                        alert(data.msg)
                    }
                }
            });

        }
    });

   

    $('input[type=submit]', '#post').removeAttr('disabled');


});